﻿using Microsoft.Phone.Shell;
using System;
using System.Collections.Generic;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;

namespace Conqueror.WP.Utility
{
    public class User
    {
        private static User _instance;
        public static User Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new User();
                return _instance;
            }
        }

        private string username = "";
        public static string Username { get { return Instance.username; } set { Instance.username = value; } }

        public static void Save()
        {
            ApplicationData.Current.RoamingSettings.Values["user_name"] = Username;
            //IsolatedStorageSettings.ApplicationSettings.Save();
        }

        public static void Load()
        {
            try
            {
                string username = ApplicationData.Current.RoamingSettings.Values["user_name"] as string;
                if (!String.IsNullOrWhiteSpace(username))
                    Username = username;
            }
            catch { }
        }
    }
}
